package com.weixin.paleituo.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;

import com.weixin.paleituo.R;
import com.weixin.paleituo.util.UIUtils;

/**
 * Author yichao
 * Time  2017/12/1 0:38
 * Dest  我的下级
 */

public class MyBelowRecyclerViewAdapter extends RecyclerView.Adapter<MyBelowRecyclerViewAdapter.ViewHolder> {


    private Context mContext;

    public MyBelowRecyclerViewAdapter(Context context) {
        mContext = context;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view= UIUtils.inflate(mContext,R.layout.item_mybelow_layout,parent,false);

        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder,final int position) {

if (mOnItemClickListener!=null){
    holder.mItemView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mOnItemClickListener.onClick(v,position);
        }
    });


}
    }

    @Override
    public int getItemCount() {
        return 20;
    }

    public class ViewHolder extends RecyclerView.ViewHolder {

        private View mItemView;

        public ViewHolder(View itemView) {
            super(itemView);
            mItemView = itemView;
        }
    }
private OnItemClickListener mOnItemClickListener;
    public interface OnItemClickListener{
      public   void onClick(View v, int position);

    }
public void setOnItemClickListener(OnItemClickListener onItemClickListener){
        this.mOnItemClickListener=onItemClickListener;

}

}
